home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
ASM32PM.ZIP
/
FILE.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-06-07
|
11KB
|
476 lines
; OPENFILE = 1
; READFILE = 1
; WRITEFILE = 1
; LSEEKFILE = 1
; CREATEFILE = 1
; FILESIZE = 1
; FILECOPY = 1
; DELETEFILE = 1
; FINDFILE = 1
.386p
code32 segment para public use32
assume cs:code32, ds:code32
include pmode.inc
public _filebufloc, _filebuflen
public _closefile
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
; DATA
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
_filebufloc dd 0 ; location must be in low mem
_filebuflen dw 4000h
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
; CODE
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
ifdef CREATEFILE
public _createfile
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Create file
; In:
; EDX -> ASCIIZ filename
; Out:
; CF=1 - Error creating file
; CF=0 - File created succesfully
; V86R_BX - file handle
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_createfile:
push ax
push edx
add edx,_code32a
mov ax,dx
shr edx,4
and ax,0fh
mov v86r_dx,ax
mov v86r_ds,dx
mov v86r_ax,3c00h
mov v86r_cx,20h
mov al,21h
int 33h
mov ax,v86r_ax
mov v86r_bx,ax
pop edx
pop ax
ret
endif
ifdef OPENFILE
public _openfile
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Open file
; In:
; EDX -> ASCIIZ filename
; Out:
; CF=1 - Error opening file
; CF=0 - File opened succesfully
; V86R_BX - file handle
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_openfile:
push ax
push edx
add edx,_code32a
mov ax,dx
shr edx,4
and ax,0fh
mov v86r_dx,ax
mov v86r_ds,dx
mov v86r_ax,3d02h
mov al,21h
int 33h
mov ax,v86r_ax
mov v86r_bx,ax
pop edx
pop ax
ret
endif
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Close a file
; In:
; V86R_BX - file handle
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_closefile:
push ax
mov v86r_ax,3e00h
mov al,21h
int 33h
pop ax
ret
ifdef DELETEFILE
public _deletefile
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Delete a file
; In:
; EDX -> ASCIIZ filename
; Out:
; CF=1 - Error opening file
; CF=0 - File opened succesfully
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_deletefile:
push ax
push edx
add edx,_code32a
mov ax,dx
shr edx,4
and ax,0fh
mov v86r_dx,ax
mov v86r_ds,dx
mov v86r_ah,41h
mov al,21h
int 33h
pop edx
pop ax
ret
endif
ifdef LSEEKFILE
public _lseekfile
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Seek position in file
; In:
; V86R_BX - file handle
; EAX - signed offset to move to
; BL - from: 0-beginning of file, 1-current location, 2-end of file
; Out:
; CF=1 - Error seeking in file
; EAX - ?
; CF=0 - Seek fine
; EAX - new offset from beginning of file
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_lseekfile:
mov v86r_ah,42h
mov v86r_al,bl
mov v86r_dx,ax
shr eax,16
mov v86r_cx,ax
mov al,21h
int 33h
pushf
mov ax,v86r_dx
shl eax,16
mov ax,v86r_ax
popf
ret
endif
ifdef FILESIZE
public _filesize
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Get size of file
; In:
; V86R_BX - file handle
; Out:
; CF=1 - Error checking file
; EAX - ?
; CF=0 - chek fine
; EAX - size of file
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_filesize:
mov v86r_ax,4201h
xor eax,eax
mov v86r_cx,ax
mov v86r_dx,ax
mov al,21h
int 33h
push v86r_dx
push v86r_ax
mov v86r_ax,4202h
xor eax,eax
mov v86r_cx,ax
mov v86r_dx,ax
mov al,21h
int 33h
mov ax,v86r_dx
shl eax,16
mov ax,v86r_ax
pop v86r_dx
pop v86r_cx
mov v86r_ax,4200h
push eax
mov al,21h
int 33h
pop eax
ret
endif
ifdef READFILE
public _readfile
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Read from file
; In:
; V86R_BX - file handle
; EDX -> buffer to read to
; ECX - number of bytes to read
; Out:
; CF=1 - Error reading file
; EAX - ?
; CF=0 - Read went fine
; EAX - number of bytes read
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_readfile:
pushad
xor ebp,ebp
add edx,_code32a
lea ebx,[ecx+edx]
cmp ebx,100000h
ja readlong
mov eax,edx
shr eax,4
and dx,0fh
mov v86r_ds,ax
mov v86r_dx,dx
readl:
mov eax,0fff0h
cmp eax,ecx
jbe readlf1
mov eax,ecx
readlf1:
mov v86r_cx,ax
mov v86r_ax,3f00h
mov al,21h
int 33h
jc readdone2
movzx ebx,v86r_ax
add ebp,ebx
sub ecx,ebx
jbe readdone
or ebx,ebx
jz readdone
add v86r_ds,0fffh
jmp readl
readlong:
mov edi,edx
sub edi,_code32a
mov edx,ecx
mov eax,_filebufloc
add eax,_code32a
mov ebx,eax
shr eax,4
and bx,0fh
mov v86r_ds,ax
mov v86r_dx,bx
movzx ebx,_filebuflen
readlongl:
mov eax,ebx
cmp eax,edx
jbe readlonglf1
mov eax,edx
readlonglf1:
mov v86r_cx,ax
mov v86r_ax,3f00h
mov al,21h
int 33h
jc short readdone2
movzx ecx,v86r_ax
add ebp,ecx
mov eax,ecx
or eax,eax
jz readdone
mov esi,_filebufloc
rep movsb
sub edx,eax
ja readlongl
readdone:
clc
readdone2:
mov [esp+28],ebp
popad
ret
endif
ifdef WRITEFILE
public _writefile
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; Write to file
; In:
; V86R_BX - file handle
; EDX -> buffer to write from
; ECX - number of bytes to write
; Out:
; CF=1 - Error writing file
; EAX - ?
; CF=0 - Write went fine
; EAX - number of bytes read
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
_writefile:
pushad
xor ebp,ebp
add edx,_code32a
lea ebx,[ecx+edx]
cmp ebx,100000h
ja writelong
mov eax,edx
shr edx,4
and ax,0fh
mov v86r_ds,dx
mov v86r_dx,ax
writel:
mov eax,0fff0h
cmp eax,ecx
jbe writelf1
mov eax,ecx
writelf1:
mov v86r_cx,ax
mov v86r_ax,4000h
mov al,21h
int 33h
jc writedone2
movzx ebx,v86r_ax
add ebp,ebx
sub ecx,ebx
jbe writedone
add v86r_ds,0fffh
jmp writel
writelong:
mov esi,edx
sub esi,_code32a
mov edx,ecx
mov eax,_filebufloc
add eax,_code32a
mov ebx,eax
shr eax,4
and bx,0fh
mov v86r_ds,ax
mov v86r_dx,bx
movzx ebx,_filebuflen
writelongl:
mov eax,ebx
c